<?php

namespace App\Models\Access\Role\Traits\Relationship;

/**
 * Class RoleRelationship
 * @package App\Models\Access\Role\Traits\Relationship
 */
trait RoleRelationship
{
    /**
     * @return mixed
     */
    public function users()
    {
        return $this->belongsToMany(\App\Models\Access\User\User::class, 'assigned_roles', 'role_id', 'user_id');
    }

    /**
     * @return mixed
     */
    public function permissions()
    {
        return $this->belongsToMany(\App\Models\Access\Permission\Permission::class, 'permission_role', 'role_id', 'permission_id')->orderBy('name', 'asc');

    }
}